home *** CD-ROM | disk | FTP | other *** search
- package sun.net.www.auth;
-
- import java.io.FileInputStream;
- import java.io.FileOutputStream;
- import java.io.IOException;
- import java.io.InputStream;
- import java.io.OutputStream;
-
- public class basic extends Authenticator {
- private static byte[] six2print = new byte[]{65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47};
- private static byte[] print2six = new byte[128];
- static final int ILLEGAL = -1;
-
- public void encrypt(InputStream var1, OutputStream var2) throws IOException {
- int var4 = -1;
- int var5 = 64;
-
- label33:
- while(true) {
- int var6 = 24;
- int var3 = 0;
-
- while(true) {
- var6 -= 8;
- if (var6 < 0) {
- var6 = 24;
-
- while(true) {
- var6 -= 6;
- if (var6 < 0) {
- var5 -= 4;
- if (var5 == 0) {
- var2.write(10);
- var5 = 64;
- }
- continue label33;
- }
-
- var2.write(six2print[var3 >> var6 & 63]);
- }
- }
-
- switch (var4 = var1.read()) {
- case -1:
- switch (var6) {
- case 0:
- var2.write(six2print[var3 >> 18 & 63]);
- var2.write(six2print[var3 >> 12 & 63]);
- var2.write(six2print[var3 >> 6 & 63]);
- var2.write(61);
- return;
- case 8:
- var2.write(six2print[var3 >> 18 & 63]);
- var2.write(six2print[var3 >> 12 & 63]);
- var2.write(61);
- var2.write(61);
- return;
- case 16:
- default:
- return;
- }
- default:
- var3 |= var4 << var6;
- }
- }
- }
- }
-
- public void decrypt(InputStream var1, OutputStream var2) throws IOException {
- int var6 = 64;
-
- int var4;
- int var5;
- label46:
- while(true) {
- var4 = 24;
- var5 = 0;
-
- while(true) {
- var4 -= 6;
- if (var4 < 0) {
- var4 = 24;
-
- while(true) {
- var4 -= 8;
- if (var4 < 0) {
- var6 -= 4;
- continue label46;
- }
-
- var2.write(var5 >> var4 & 255);
- }
- }
-
- int var3;
- switch (var3 = var1.read()) {
- case -1:
- if (var4 == 18) {
- throw new IOException("Invalid encryption");
- }
- break label46;
- case 10:
- if (var6 != 0) {
- throw new IOException("Invalid encryption");
- }
-
- var6 = 64;
- continue label46;
- case 61:
- break label46;
- default:
- byte var7 = print2six[var3];
- switch (var7) {
- case -1:
- throw new IOException("Invalid encryption");
- default:
- var5 |= var7 << var4;
- }
- }
- }
- }
-
- switch (var4) {
- case 0:
- var2.write(var5 >> 16 & 255);
- var2.write(var5 & 255);
- return;
- case 6:
- var2.write(var5 >> 16 & 255);
- return;
- case 12:
- throw new IOException("Invalid encryption");
- case 18:
- default:
- }
- }
-
- public static void main(String[] var0) throws IOException {
- basic var1 = new basic();
- FileOutputStream var2 = new FileOutputStream("/home/jpayne/livejava/test.uu");
- ((Authenticator)var1).encrypt(new FileInputStream("/home/jpayne/livejava/test.ascii"), var2);
- var2.close();
- ((Authenticator)var1).decrypt(new FileInputStream("/home/jpayne/livejava/test.uu"), System.out);
- System.out.flush();
- }
-
- static {
- int var1 = six2print.length;
- int var0 = print2six.length;
-
- while(true) {
- --var0;
- if (var0 < 0) {
- var0 = 0;
-
- while(true) {
- --var1;
- if (var1 < 0) {
- return;
- }
-
- print2six[six2print[var0]] = (byte)var0;
- ++var0;
- }
- }
-
- print2six[var0] = -1;
- }
- }
- }
-